package cn.edu.hnnu.a.rentacar.dao.hibernateimpl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import cn.edu.hnnu.a.rentacar.beans.RentRecord;
import cn.edu.hnnu.a.rentacar.idao.IRentRecordDAO;
import cn.edu.hnnu.a.rentacar.util.HibernateUtil;

public class RentRecordDAOHibernateImpl implements IRentRecordDAO {
	private static RentRecordDAOHibernateImpl instance;

	private RentRecordDAOHibernateImpl() {

	}

	public static RentRecordDAOHibernateImpl getInstace() {
		if (null == instance) {
			instance = new RentRecordDAOHibernateImpl();
		}
		return instance;
	}

	@Override
	public void addRentRecord(RentRecord rentRecord) {
		SessionFactory factory = HibernateUtil.getSessionFactory();
		Session session = factory.openSession();
		Transaction tran = session.beginTransaction();
		session.save(rentRecord);
		tran.commit();
		session.close();

	}
}
